package com.hbk.base.auth;

import com.hbk.base.exception.NoTokenException;
import lombok.Data;

@Data
public class JWTInfo {

    private String userId;
    private String userType;
    private Long loginTime;
    private String origin;

    private static ThreadLocal<JWTInfo> myInfo = new ThreadLocal<>();

    public static void set(JWTInfo info){
        myInfo.set(info);
    }

    public static JWTInfo get(){
        JWTInfo info = myInfo.get();
        if(info==null){
            throw new NoTokenException();
        }
        return info;
    }

    public static void remove(){
        myInfo.remove();
    }
}
